home *** CD-ROM | disk | FTP | other *** search
- Path: dawn.mmm.com!news
- From: kjhopps@mmm.com (Kevin J Hopps)
- Newsgroups: comp.lang.c++
- Subject: Re: strcpy problem
- Date: 19 Feb 1996 20:20:06 GMT
- Organization: 3M - St. Paul, MN 55144-1000 US
- Message-ID: <4gam1m$4q7@dawn.mmm.com>
- References: <31261C92.3DEE@intersurf.com>
- Reply-To: kjhopps@mmm.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- David C. Branton (dbranton@intersurf.com) wrote:
- > strcpy does not seem to work in this case. Can anyone explain why?
-
- > Here is the setup:
-
- > class league
- > { protected:
- > ...
- > struct franchise
- > {...
- > struct person
- > { char name [25];
- > ...
- > }
- > }team [12];
- >
- > public:
- > void draftplayer ();
- > ...
- > };
-
- > void league::draftplayer()
- > {
- > char playername[25];
- > ...
-
- > // playername is given a value; tracing confirms that it has a value
-
- > strcpy(team[draftpick-1].player[round-1].name, playername);
-
- > ...
-
- > }
-
- > The line strcpy... does not copy the string. When code is traced, there
- > is a proper value for playername but nothing gets copied into the nested
- > structure. All variable have been properly declared and have values at
- > this point.
-
- > Any ideas as to why strcpy does not work in this case?
-
- Could it be too complicated an expression for your compiler? Perhaps you
- could break the expression into simpler statements. If this produces a
- better result, report a bug to your compiler vendor.
- --
- Kevin J. Hopps e-mail: kjhopps@mmm.com
- 3M Company phone: (612) 737-4643
- 3M Center, Bldg. 235-2D-57 fax: (612) 737-2700
- St. Paul, MN 55144-1000 Opinions are my own. I don't speak for 3M.
- But 3M speaks for me -- I did not write the following line:
-
- Opinions expressed herein are my own and may not represent those of 3M.
-